<?
//inculde即可以使用data数据。本页所有的data数据，倾在controller都处理好
include_once("../../../common/module/checkA.php");
include_once("../../../../config.php");
include_once("../controller/detail-list.php");
?>



<?

//获取本页用到的单位的名字
$unit_nid_list=transform_2darray_in_1darray_with_new_key($detail,"nid","unit");
$unit_nid_list_str=implode("','",$unit_nid_list);
$unit_list=select_lines_all_items($table_Prefix."unit","","nid in ('".$unit_nid_list_str."')","");
$unit_name_list=transform_2darray_in_1darray_with_new_key($unit_list,"nid","sname");

?>
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <?php include ROOT_PATH_.'/controller/common/module/head.php'; ?>
    <?php include 'modules/head.php'; ?>
</head>

<body>

<div id="topbar">   <?php include ROOT_PATH_.'/controller/common/module/topbar.php'; ?></div>

<div id="container" class="<? echo $system_part ?>">

    <div id="maincontent">

        <div id="sidebar">
            <?php include ROOT_PATH_.'/controller/common/module/sidebar.php'; ?>
        </div>




<div id="content">


    <!--标题设定-->
    <?php $page_title=$_plate['name'].'列表';?>
    <?php include $_SERVER['DOCUMENT_ROOT']. '/controller/common/module/mod-page-title.php'; ?>


<div class=" select-box layui-form">





    <form action="detail-list.php" >

    <div class="layui-form-item">
        <label class="layui-form-label">关键词</label>
        <div class="layui-input-block">
            <input type="text" name="select_keywords" placeholder="项目名称 | 单位名称" autocomplete="off" class="layui-input" value="<? echo $_REQUEST['select_keywords']?>" >
        </div>
    </div>




    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>

        <div class="layui-input-block">
            <input type="text" name="select_startday" placeholder="请输入开始时间" autocomplete="off" class="layui-input"  onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" style="float: left; width: 112px" value="<?if($_REQUEST['select_startday']){echo $_REQUEST['select_startday'] ;} ?>" >

            <span style="float: left;margin: 0 4px; line-height: 30px;">-</span>


            <input type="text" name="select_endday" placeholder="请输入结束时间" autocomplete="off" class="layui-input" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  style="float: left; width:112px" value="<?if($_REQUEST['select_endday']){echo $_REQUEST['select_endday'] ;} ?>"  >


            <input type="hidden" name="nav-itemed"  value="case" >


        </div>


    </div>





    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <select name="select_status">
                <?if($_REQUEST['select_status']){echo "<option value='".$_REQUEST['select_status']."'>".$_REQUEST['select_status']."</option>";}?>

                <option value="全部">全部</option>
                <option value="完成">完成</option>
                <option value="进行中">进行中</option>
                <option value="售后维护">售后维护</option>
                <option value="自然流失">自然流失</option>
                <option value="我放终止">我放终止</option>
                <option value="客户终止">客户终止</option>
                <option value="其他">其他</option>
                <option value="询价中">询价中</option>

            </select>
        </div>
    </div>







    <button class="layui-btn" ><i class="layui-icon">&#xe615;</i> 查找</button>
    <a class="layui-btn" href="detail-list.php?nav-itemed=case" ><i class="layui-icon">&#x1006;</i> 重置</a>

    <br class="clearfloat"/>
</form>

    <br class="clearfloat"/>
</div>












<!-- 用$system_part .list_boxes来控制来到确认板块信息显示-->
    <!-- 用$system_part .list_boxes来控制来到确认板块信息显示-->
<div class="list-box">

<div class="list-boxes layui-form">


<table class="layui-table">
  <colgroup>

    <col width="280">
    <col width="95">
    <col >
    <col width="70">
    <col >
    <col >
    <col >
    <col width="350">
    <col width="60">
    <col width="230">

  </colgroup>
  <thead>
    <tr>
      <th>名称</th>
      <th>状态</th>
      <th>时间</th>
      <th>类型</th>
      <th>总额</th>
      <th>财务</th>
      <th>任务</th>
      <th>项目进度</th>
      <th>人员</th>
      <th>操作</th>

    </tr> 
  </thead>
  <tbody>





<?php
for ($i = 0; $i < $detailnum; $i++) {
?>




<tr id="item<?echo $detail[$i]['nid']?>" <?if($applymodify['nid']){echo "style='color:red'";$status="审核中";}else{$status="正常";}?>>


<td>
    <span class="els1">【<a href="../../unit/view/detail-statistic.php?sys_part=unit&nid=<?echo $detail[$i]['nid']?>"><?echo $unit_name_list[$detail[$i]['unit']]?></a>】
    <?echo $detail[$i]['name']?></span>
</td>

<td><span
    <?if($detail[$i]['status']=='进行中')
    {echo "class='layui-badge'  style='background-color:#ff9900'";}elseif ($detail[$i]['status']=='售后维护'){echo "class='layui-badge layui-bg-green'";}?>>
        <?echo $detail[$i]['status']?>
    </span>
</td>

<td><?echo substr($detail[$i]['startdate'],0,10)?> - <?echo substr($detail[$i]['enddate'],0,10)?> / <?echo count_days($detail[$i]['startdate'],$detail[$i]['enddate'])?> 日 </td>



<!-- <td><?echo $detail[$i]['type']?></td> -->
<td>
    <? $type_color = 'layui-bg-green';$type_name=$detail[$i]['type'];?>
    <?if($detail[$i]['type']=='谷歌推广及网站开发'){ $type_color = 'layui-bg-green';$type_name='谷歌';}?>
    <?if($detail[$i]['type']=='谷歌推广'){ $type_color = 'layui-bg-green';$type_name='谷歌';}?>
    <?if($detail[$i]['type']=='国际站代运营'){ $type_color = 'layui-badge';$type_name='阿里';}?>
    <?if($detail[$i]['type']=='国际站纯投放'){ $type_color = 'layui-badge';$type_name='阿里';}?>
    <?if($detail[$i]['type']=='网站开发'){ $type_color = 'layui-bg-blue';$type_name='网站';}?>
    <?if($detail[$i]['type']=='混合'){ $type_color = 'layui-bg-blue';$type_name='混合';}?>
    <?if($detail[$i]['type']=='宝贝描述'){ $type_color = 'layui-bg-blue';$type_name='宝贝描述';}?>
    <?if($detail[$i]['type']=='其他'){ $type_color = 'layui-bg-gray';$type_name='其他';}
    else{ $type_color = 'layui-bg-green';

            $type_name=utf8_substr(['str'=>$detail[$i]['type'],'from'=>'0','len'=>3]);}
    ?>

    <span class="layui-badge <?echo $type_color?>">
    <?echo $type_name?>
    </span>
</td>

<td><?echo $detail[$i]['sum']?></td>


<?php $finance=select_lines_all_items($table_Prefix."finance","","caseid = '".$detail[$i]['nid']."'"); ?>
<td>
    <?
    $check_finance=count_value_with_key_in_2d_array($finance,'status','过账');
    if(count($finance)>0){?>
        <?if(count($check_finance)>0){echo $check_finance;}else{echo "0";} ?>/
        <?echo count($finance)?>
    <?}else{echo "无";}?>
</td>

    <?php
    $task=select_lines_all_items($table_Prefix."task","","case_id = '".$detail[$i]['nid']."'");
    $check_task=count_value_with_key_in_2d_array($task,'status','已完成');
    ?>
    <td>
        <?if(count($task)>0){?>
            <?if(count($check_task)>0){echo $check_task;}else{echo "0";} ?>/
        <?echo count($task)?>
        <?}else{echo "无";}?>
    </td>


<?php
    //当前时间戳
    $now = time();
    //项目开始时间的时间戳
    $start_time = strtotime($detail[$i]['startdate']);
    //项目结束时间的时间戳
    $end_time = strtotime($detail[$i]['enddate']);
    //计算进度（月份） 项目开始时间和当前的时间相差几个月
    $done_time = count_month($detail[$i]['startdate'],date('Y-m-d H:i:s'));
    //计算项目需要完成的时间（月份）
    $total_time = count_month($detail[$i]['startdate'],date('Y-m-d H:i:s',strtotime("+1 day",strtotime($detail[$i]['enddate']))));
    //项目还未开始
    if($now < $start_time){
        $progress = '';
    //项目已经结束
    }else if($now > $end_time){
        $progress = $total_time.' / '.$total_time;
    //计算正常情况下的进度
    }else{
        $progress = $done_time.' / '.$total_time;
    }
?>

<!--<td>-->
<!--    <div class="layui-progress layui-progress-big" lay-showpercent="true">-->
<!--        <div class="layui-progress-bar" lay-percent="--><?php //echo $progress; ?><!--"></div>-->
<!--    </div>-->
<!--</td>-->


    <td>
        <div  >
        <?
        if($total_time>36){$total_time=36;}
        for($ii=1;$ii<=$total_time;$ii++){?>
            <span class="layui-badge <?if($done_time<$ii){echo "layui-bg-green";}?>" style="background-color:#999;max-width:10.4px;width:<?echo 250/$total_time?>px" >
                <?echo $ii;?>
            </span>
            <?;}?>
        </div>
    </td>




<td style="text-align: center">
    <?
        $work_num=0;
        if($detail[$i]['agent']>0){$work_num++;}
        if($detail[$i]['respon']>0){$work_num++;}
        if($detail[$i]['dist_sales']>0){$work_num++;}
        if($detail[$i]['sales']>0){$work_num++;}
        if($detail[$i]['service']>0){$work_num++;}
        if($detail[$i]['programer']>0){$work_num++;}
        if($detail[$i]['designer']>0){$work_num++;}
        if($detail[$i]['editor']>0){$work_num++;}
        if($detail[$i]['operator']>0){$work_num++;}
        echo $work_num;
        ?>

</td>



    <td>


<a href="detail-info.php?nid=<? echo $detail[$i]['nid']?>&<?= $data['url_parameter'] ?>"
   class="layui-btn  layui-btn-xs" target="_blank" ><i class="layui-icon">&#xe621;</i>信息</a>


        <a href="detail-edit.php?nid=<? echo $detail[$i]['nid']?>&<?= $data['url_parameter'] ?>"
           class="layui-btn  layui-btn-xs" >
            <i class="layui-icon">&#xe642;</i>修改 
        </a>


<a href="javascript:void(0)" onclick="delItem (<?php echo $detail[$i]['nid']?>)"
   class="delete layui-btn  layui-btn-xs layui-bg-red" >
    <i class="layui-icon">&#xe640;</i> 删除 </a>



  </td>
    </tr>
<?}?>

 
  </tbody>
</table>




 

</div>


<div class="list-box-function"
<? if ($detailnum == 0) {
    echo "style" . "='display:none'";
} ?>
>

    <?php include 'page_numbers.php'; ?>

</div>




<!--list-box end-->
</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>







<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?>
</body>
</html>